[% setvar title C<chomp()> changes. %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p><code>chomp()</code> changes.</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: Ted Ashton &lt;<a href='mailto:ashted@southern.edu'>ashted@southern.edu</a>&gt;
  Date: 7 Aug 2000
  Mailing List: <a href='mailto:perl6-language@perl.org'>perl6-language@perl.org</a>
  Number: 58
  Version: 1
  Status: Developing</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>The current return value of <code>chomp()</code> is little-used and tends to confuse
those learning perl.  Here is presented a change to <code>chomp()</code>'s return value
and to the <code>while(&lt;FILEHANDLE&gt;)</code> construction.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>This RFC contains two proposed changes.  First, as it is common to want to
removed newlines upon reading a file,</p>
<pre>  while (chomp(&lt;FILEHANDLE&gt;)) {
    . . .
  }</pre>
<p>should become the equivalent of</p>
<pre>  while (&lt;FILEHANDLE&gt;) {
    chomp;
    . . .
  }</pre>
<p>or, to put it more explicitly,</p>
<pre>  while (defined($_ = &lt;FILEHANDLE&gt;)) {
    chomp $_;
    . . .
  }</pre>
<p>where the various equivalent constructions would, of course, work as expected.</p>
<p>Second, as it seems common for someone learning perl to expect</p>
<pre>  $without_newline = chomp($previous_form);</pre>
<p>to put a copy of the text in <code>$previous_form</code>, sans newline, into
<code>$without_newline</code> while not modifying <code>$previous_form</code>, Perl should
do just that.</p>
<p><code>chomp()</code> called in void context would remove the newline
from the variable (or members of the list) upon which it was called.
<code>chomp()</code> called in a scalar context would leave its argument variable
untouched and instead return a <code>chomp()</code>ed version of that variable's
contents.  Likewise and furthermore for other contexts.</p>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>As I know little about perl5 internals and even less about perl6, I shall
simply present the following notes:</p>
<ul>
<li><a name='This proposal does not speak to what should happen with chop().'></a>This proposal does not speak to what should happen with <code>chop()</code>.</li>
<li><a name='The proposed demise of $/ and stated determination that there will be no default filehandle will have an effect on chomp(). After all, that's how it determines which character to seek at the end of the line.'></a>The proposed demise of <code>$/</code> and stated determination that there will be no
default filehandle will have an effect on <code>chomp()</code>.  After all, that's how
it determines which character to seek at the end of the line.</li>
</ul>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<pre>  The Camel II, pp 53 and 149.</pre>
</div>
